import {
    createSlice
} from '@reduxjs/toolkit'

const countSlice = createSlice({
    //创建type和基本数据
    name: 'counter',

    //reducer提供的初始值
    initialState:{
        count:0
    },

    //创建reducer
    reducers:{
        incrementAction(prev,action){
            console.log(prev.count,action,'这是countslice');
            prev.count += action.payload
        },

        decrementAction(prev,action){
            prev.count -= action.payload
        }
    }
})

export default countSlice.reducer   //创建对象上的reducer属性，暴露出去给store使用

//暴露action
export const{
    incrementAction,
    decrementAction
} = countSlice.actions
console.log(countSlice);